import request from '@/config/axios'
import type { UserType } from './types'

interface RoleParams {
  roleName: string
}
// 登录验证码
export const loginApi = (data: any) => {
  return request.post({ url: '/api/auth/login', data })
}
// 企业注册
export const tenantApi = (data: any) => {
  return request.post({ url: '/api/enterprise/tenant', data })
}

export const loginOutApi = (): Promise<IResponse> => {
  return request.get({ url: '/user/loginOut' })
}
// login获取验证
export const imgcdeApi = (params: any) => {
  return request.get({ url: '/api/auth/code' })
}
// 重置密码
export const restPasswordApi = (params: any) => {
  return request.post({ url: '/api/auth/restPassword', data: params })
}
// 修改密码
export const resetPwdApi = (params: any) => {
  return request.post({ url: '/api/enterprise/user/updatePassword', data: params })
}
//获取手机号验证码
export const phoneApi = (params: any) => {
  return request.get({ url: '/api/resource/sms/code',params})
}
// 获取字典
export const getselect = (params: any) => {
  return request.get({ url: '/api/enterprise/dict/type/'+params})
}
// 获取全部字典
export const getDict = () => {
  return request.get({ url: '/api/dict'})
}
// 获取隐私政策
// 获取接口数据隐私政策和服务
export const configKey=(params) =>{
  return request.get({ url: "/api/config/configKey/"+params})
}

export const getInfo = () => {
  return request.get({ url: '/api/enterprise/user/getInfo'})
}
export const getUserListApi = ({ params }: AxiosConfig) => {
  return request.get<{
    code: string
    data: {
      list: UserType[]
      total: number
    }
  }>({ url: '/user/list', params })
}

export const getAdminRoleApi = (
  params: RoleParams
): Promise<IResponse<AppCustomRouteRecordRaw[]>> => {
  return request.get({ url: '/role/list', params })
}

export const getTestRoleApi = (params: RoleParams): Promise<IResponse<string[]>> => {
  return request.get({ url: '/role/list', params })
}
